﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConceptsFramework.AbstractConceptElements;
using ConceptsFramework.Containers.Global;

namespace ConceptsFramework.Strategies.Clusters.Instances
{
    public class PerTypeClusterStrategy : AbstractOneLevelClusterStrategy
    {
        public override string OneLevelClusterStrategyName
        {
            get { return "TYPECLUSTER"; }
        }

        
        private AbstractRelationship GetFirstRelationship(RelationshipsGroup aGroup)
        {
            if (aGroup.RelationshipFlatContainer.Values.Count==0)
                throw new ApplicationException("Unexpected RelationshipGroup with no content");
            return aGroup.RelationshipFlatContainer.Values.Take(1).First();
        }

        protected override bool AddToCurrentGroup(AbstractRelationship analyzedRelationship, RelationshipsGroup aRelationshipGroup)
        {
            return (analyzedRelationship.GetType() == GetFirstRelationship(aRelationshipGroup).GetType());
        }

        protected override string GetRelationshipGroupMetadata(RelationshipsGroup aRelationshipGroup)
        {
            return GetFirstRelationship(aRelationshipGroup).GetType().ToString();
        }

       
    }
}
